package com.fm.financemanage.service;

import com.fm.financemanage.mapper.CompanyClassifyMapper;
import com.fm.financemanage.mapper.CustomerClassifyConfigMapper;
import com.fm.financemanage.mapper.CustomerCompanyAccountConfigMapper;
import com.fm.financemanage.model.po.CompanyClassify;
import com.fm.financemanage.model.po.CustomerCompanyInfo;
import com.fm.financemanage.model.vo.PageVo;
import com.fm.financemanage.model.vo.company.CustomerCompanyInfoListVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class ClassifyService {

    @Resource
    private CompanyClassifyMapper companyClassifyMapper;


    public PageVo<List<CompanyClassify>> getList(Integer page, Integer limit) {

        return new PageVo<List<CompanyClassify>>(companyClassifyMapper.getList((page - 1) * limit, limit),
                companyClassifyMapper.count());

    }

    public void operator(CompanyClassify companyClassify) {

        if (companyClassify.getId() == null) {
            companyClassify.setCreateTime(LocalDateTime.now());
            companyClassify.setUpdateTime(LocalDateTime.now());
            companyClassify.setState(1);
            companyClassifyMapper.insertSelective(companyClassify);
        } else {
            companyClassify.setUpdateTime(LocalDateTime.now());
            companyClassifyMapper.updateByPrimaryKeySelective(companyClassify);
        }
    }

    public void removeById(Integer id) {
        companyClassifyMapper.deleteByPrimaryKey(id);
    }
}
